/*
 * ${beanName}ServiceImpl.java created on ${config.createTime?string("yyyy-MM-dd")} by ${config.createUser}
 */
package ${config.pack}.service.impl;

import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import ${config.pack}.entity.${beanName};
import ${config.pack}.entity.${beanShowVo};
import ${config.pack}.entity.${beanQueryVo};
import ${config.pack}.service.${beanName}Service;

import framework.common.BaseMapper;
import framework.common.Page;
import framework.common.Result;
import framework.utils.IDUtils;

/**
 * ${config.beanDescription} Service 实现
 * TODO javadoc for ${config.pack}.service.impl.${beanName}ServiceImpl
 * @Copyright: ${config.copyright}
 * @author: ${config.createUser}
 * @since: ${config.createTime?string("yyyy-MM-dd HH:mm:ss")}
 */
@Service
public class ${beanName}ServiceImpl implements ${beanName}Service {

	@Autowired
	private BaseMapper mapper;

	@Transactional
	@Override
	public Result create(${beanName} ${simpleBeanName}) {
		Result result=new Result();
		${simpleBeanName}.set${columnList[0].javaPropertyName?cap_first}(IDUtils.genUUID());
		mapper.${simpleBeanName}Mapper.add(${simpleBeanName});
		return result;
	}

	@Override
	public ${beanName} getById(String ${beanId})  {
		return mapper.${simpleBeanName}Mapper.getById(${beanId});
	}

	@Transactional
	@Override
	public Result edit(${beanName} ${simpleBeanName})  {
		Result result=new Result();
		mapper.${simpleBeanName}Mapper.edit(${simpleBeanName});
		return result;
	}

	@Transactional
	@Override
	public Result delete(String ${beanId})  {
		 mapper.${simpleBeanName}Mapper.deleteById(${beanId});
		 return new Result();
	}

	@Override
	public Page<${beanShowVo}> search(Page<${beanShowVo}> pager, ${beanQueryVo} ${simpleBeanName})  {
		List<${beanShowVo}> dataList = mapper.${simpleBeanName}Mapper.getPage(${simpleBeanName},new RowBounds((pager.getPage() - 1) * pager.getRows(), pager.getRows()));
		pager.setDataList(dataList);
		Long total =mapper.${simpleBeanName}Mapper.getPageTotal(${simpleBeanName});
		pager.setTotal(total);
		return pager;
	}
}
